package com.example.douyintest;

import android.os.Message;
import android.view.accessibility.AccessibilityNodeInfo;

import com.levine.abllib.AblStepBase;
import com.levine.abllib.AblStepHandler;
import com.levine.abllib.AblSteps;
import com.levine.abllib.callback.AniCallBack;
import com.levine.abllib.utils.AblViewUtil;

public class TestAblStep1 extends AblStepBase {
//适用于17.4.0版本的抖音
    @Override
    public void onStep(int step, Message msg) {
        switch (step) {
            case AblSteps.STEP_1://找到“我”
                AblViewUtil.clickScreen(18,19);
                AblStepHandler.sendMsg(AblSteps.STEP_2);
                break;
            case AblSteps.STEP_2://找到切换账号选项
                AblViewUtil.findById("com.ss.android.ugc.aweme:id/j0+", 0, new AniCallBack() {
                    @Override
                    public void succ(AccessibilityNodeInfo info) {
                        info.performAction(AccessibilityNodeInfo.ACTION_CLICK);
                        AblStepHandler.sendMsg(AblSteps.STEP_3);
                    }
                });
                break;
            case AblSteps.STEP_3://根据当前账号的数量，用拍判断子节点数量的方式选择账号
                AblViewUtil.findById("com.ss.android.ugc.aweme:id/recycler_view", 0, new AniCallBack() {
                    @Override
                    public void succ(AccessibilityNodeInfo info) {
                        if (info.getChildCount() <= 3 ){
                            info.getChild(1).performAction(AccessibilityNodeInfo.ACTION_CLICK);
                        } else {
                            info.getChild(2).performAction(AccessibilityNodeInfo.ACTION_CLICK);
                        }
                    }
                });
                break;
        }
    }
}
